{extend name="public/base" /}
{block name='body'}
<div class="layui-container">
    <div class="fly-panel">
        <div class="layui-row">
            <div class="layui-col-md12">
                <ul class="fly-list sw-plate-box" id="sw-res-searchs-list">

                </ul>
            </div>
            <div class="layui-col-md12">
                <div id="pages" style="text-align: center"></div>
            </div>
        </div>


    </div>
</div>

{/block}


{block name='script'}

<script>
    function dataToHtml(resAttr) {
        return resTpl = ` {include file="tpl/resItems"}`;
    }

    layui.config({
        base: "__JS__/"
    }).use(['jquery', 'layer', 'laypage'], function () {
        let $ = layui.jquery, layer = layui.layer, page = layui.laypage,type="{$type}";
        //包含api文件
        {include file='__PUBLIC__/../application/home/view/api/doGet.js'}

        //请求
        $.get("{:url('index/resPageApiCount')}?type=" + type,function (res) {
            if(res.errno===0){
                //渲染分页
                page.render({
                    elem: 'pages',
                    count: res.data,
                    groups: 10,
                    jump: function (obj, index) {
                        let limit = obj.limit;
                        let page = obj.curr;
                        let api = "{:url('index/resPageApi')}?page=" + page + "&limit=" + limit+"&type="+type;
                        let loadid = layer.load();
                        doGet(api, 'sw-res-searchs-list', loadid);
                    }
                });
            }else{
                return layer.msg('服务器繁忙,请稍后再试');
            }
        });


//        doGet("{:url('index/resPageApi')}?page=1&limit=10",'sw-res-searchs-list', layer.load())

    })
</script>
{/block}